import draw.*;
import geometry.Posn;
import geometry.*;
import tester.*;
import java.util.*;
import colors.*;

class ConsLoS implements ILoS{
  Star first;
  ILoS rest;
  
  //draws the whole wide list of stars.
  public boolean drawStars(Canvas c){
    return this.first.drawStar(c) &&
           this.rest.drawStars(c);
  }
  
  //"map"s onTick across a list of stars.
  public ILoS onTick(Mfmwg m){
    if (this.first.span <= 0 || this.first.isFoundp(m) || 
        this.first.hitGroundp()){
      return new ConsLoS(this.first.makeStar(),
                         this.rest.onTick(m));
    } else { return new ConsLoS(this.first.onTick(),
                              this.rest.onTick(m));
           }
  }
  
  //have any of the stars been found?
  public boolean foundStar(Mfmwg m){
    return this.first.isFoundp(m) || this.rest.foundStar(m);
  }
  
  //return the first star that can be caught.
  //don't break it!
  public Star caughtStar(Mfmwg m){
      if(this.first.isFoundp(m)) {
        return this.first;
      } else { return this.rest.caughtStar(m);
     }
    }
     
  ConsLoS(Star first, ILoS rest) {
    this.first = first;
    this.rest = rest;
  }
  
     /*
TEMPLATE:
   FIELDS:
    ... this.first ...            --Star
    ... this.rest ...             --ILoS

    METHODS:
    ... this.drawStars(Canvas c) ...  -- boolean
    ... this.onTick(Mfmwg m) ...      -- ILoS
    ... this.foundStar(Mfmwg m) ...   -- boolean
    ... this.caughtStar(Mfmwg m) ...  -- boolean


    METHODS FOR FIELDS:
    ... this.first.onTick() ...             -- Star
    ... this.first.makeStar() ...           -- Star
    ... this.first.hitGroundp() ...         -- boolean
    ... this.first.isFoundp(Mfmwg m) ...    -- boolean
    ... this.first.drawStar(Canvas c) ...   -- boolean
    ... this.first.amIEmptyp() ...          -- boolean
    ... this.rest.drawStars(Canvas c) ...  -- boolean
    ... this.rest.onTick(Mfmwg m) ...      -- ILoS
    ... this.rest.foundStar(Mfmwg m) ...   -- boolean
    ... this.rest.caughtStar(Mfmwg m) ...  -- boolean
*/ 
}